/*
 * 全局事件注册 creator by wangjun on 2012.8.23
 */
$(function(){

});

/* 显示/隐藏更多电影介绍 */
var shortDetail;
function toggleDetail(filmIntroduce) {
    if (shortDetail == null) shortDetail = $(".detail_vbot").html();

    var content = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + filmIntroduce
        + '<a href="javascript:void(0);" onclick=$(".detail_vbot").html(shortDetail);>［隐藏］</a>';
    $(".detail_vbot").html(content);
}

//打分系统
function rate(obj,oEvent){
    if(obj.rateFlag) return;
    var e = oEvent || window.event;
    var target = e.target || e.srcElement;
    var imgArray = obj.getElementsByTagName("img");
    for(var i=0;i<imgArray.length;i++){
        imgArray[i]._num = i;
        imgArray[i].onclick=function(){
            if(obj.rateFlag) return;
            obj.rateFlag=true;

            // wangjun add
            var score = (target._num + 1) * 2;
            $.ajax({type:'POST', url:'clickScore.html', data:'filmId=' + obj.title + '&score=' + score
                , success:function(data) {
                var returnObj = eval('('+data+')');
                $("td span:eq(0)").text(returnObj.score);
                $("td span:eq(1)").text(returnObj.count);
                $(".giveScore").html("评论成功！<img src='/images/yes.png'>");
            }});
        }
    }
    if(target.tagName=="IMG"){
        for(var j=0;j<imgArray.length;j++){
            if(j<=target._num){
                var imgSrc =  imgArray[j].src;
                var newImg = imgSrc.replace("grey","green");
                imgArray[j].src=newImg;
            } else {
                var imgSrc =  imgArray[j].src;
                var newImg = imgSrc.replace("green","grey");
                imgArray[j].src=newImg;
            }
        }
    } else {
        for(var k=0;k<imgArray.length;k++){
            var imgSrc =  imgArray[k].src;
            var newImg = imgSrc.replace("green","grey");
            imgArray[k].src=newImg;
        }
    }
}

function qvodError() {
    if(window.confirm('请您先安装qvodplayer软件,然后刷新本页才可以正常播放.')) {
        window.open('http://www.qvod.com/download.htm');
    }else{
        self.location='http://www.qvod.com/';
    }
}